import {
  Toast,
  Indicator
} from "mint-ui"
import storage from 'storejs'
import store from '../store/index'
import {  UPDATE_TOAST } from "../store/mutation-types";

let Plugin = {};
Plugin.install = function (Vue, options) {

  //消息提示框
  Vue.prototype.$msg = function (msg) {
    let toast = store.state.toast;
    if(toast)toast.close();
    toast = Toast({
      message: msg,
      duration: 2000
    });
    store.commit(UPDATE_TOAST,toast);
  }

  //正在加载
  Vue.prototype.$indicator = function (bool=true) {
    bool ? Indicator.open({
      spinnerType: 'fading-circle'
    }) : Indicator.close();
  }
};
export default Plugin;
